package com.nuoniu.sibanyun.service.erp.impl;

import com.nuoniu.sibanyun.service.erp.*;
import com.nuoniu.sibanyun.service.production.IErpBomGroupService;
import com.nuoniu.sibanyun.userThread.UserInfo;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.scheduling.annotation.Async;
import org.springframework.stereotype.Service;

/**
 * @ClassName ErpInitAccountDataService
 * @Description 账套初始化工作
 * @Authpr baiqiang
 * @Date 2020/11/16 16:32
 **/
@Service
public class ErpInitAccountDataService {

    @Autowired
    private IErpAccountRuleSetService erpAccountRuleSetService;
    @Autowired
    private IErpVoucherDesignService erpVoucherDesignService;
    @Autowired
    private IErpGradeRuleService erpGradeRuleService;
    @Autowired
    private IErpNumberSetService erpNumberSetService;
    @Autowired
    private IErpInvoiceTypeService erpInvoiceTypeService;
    @Autowired
    private IErpAccountingService accountingService;
    @Autowired
    private IErpCurrencyService currencyService;
    @Autowired
    private IErpBomGroupService bomGroupService;

    /**
     * 初始化 账套必须的数据
     * @param userInfo
     * @param id
     */
    @Async
    public void init(UserInfo userInfo, Integer id){
        erpGradeRuleService.innitData( userInfo , id );  //编码规则
        erpVoucherDesignService.initDefErpVoucherDesign( userInfo ,id ); //单据设计
        erpNumberSetService.initData(userInfo,id); //编号设置
        erpAccountRuleSetService.initDefErpAccountRuleSet(userInfo ,id ); //初始化选项
        erpInvoiceTypeService.initData(userInfo,id); //发票分类
        accountingService.initData(userInfo, id); //会计科目
        currencyService.initData(userInfo, id); //币种
        bomGroupService.initData(userInfo); //bom分组
    }
}
